package com.neusoft.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import com.neusoft.po.Review;

@Mapper
public interface ReviewMapper {

	@Select("select * from review where foodId=#{foodId} order by reviewId")
	public List<Review> listReviewByFoodId(Integer foodId);

	@Select("select * from review where userId=#{userId} order by reviewId")
	public List<Review> listReviewByUserId(String userId);

	// save
	@Insert("insert into review(userId,foodId,content) values(#{userId},#{foodId},#{content})")
	@Options(useGeneratedKeys = true, keyProperty = "reviewId", keyColumn = "reviewId")
	public int saveReview(Review review);

	// remove
	@Delete("delete from review where reviewId=#{reviewId}")
	public int removeReview(Integer reviewId);

}
